package com.tjian.fafa.user.module.home.fragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.tjian.fafa.user.R;

import java.util.ArrayList;

public class NewsFragmentPagerAdapter extends FragmentPagerAdapter
{
    private ArrayList<Fragment> fragments;
    private FragmentManager fm;

    public NewsFragmentPagerAdapter(FragmentManager fm)
    {
        super(fm);
        this.fm = fm;
    }

    public NewsFragmentPagerAdapter(FragmentManager fm,
                                    ArrayList<Fragment> fragments)
    {
        super(fm);
        this.fm = fm;
        this.fragments = fragments;
    }

    @Override
    public int getCount()
    {
        return fragments.size();
    }

    @Override
    public Fragment getItem(int position)
    {
        return fragments.get(position);
    }

    @Override
    public int getItemPosition(Object object)
    {
        return POSITION_NONE;
    }

    @Override
    public Object instantiateItem(ViewGroup viewGroup, final int position)
    {

        if (viewGroup != null)
        {
            viewGroup.removeAllViewsInLayout();
        }

        Object obj = super.instantiateItem(viewGroup, position);
        return obj;
    }


}

